-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Implement RFC 640 #23162
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement RFC 640 #23162
Conversation
I'll take a closer look at this tomorrow, but I'm curious why you applied |
The public API takes |
Ah ok. If we're trying to minimize codegen though I would probably recommend a In general I'm not so sure about the application of Otherwise, my only other concern is the usage in |
I will collect some statistics. The deriving implementation uses the functionality @huonw added to be able to call unstable APIs without triggering feature gates. |
Ah excellent. cc @huonw on the |
// the internal fields we're actually formatting | ||
let mut exprs = Vec::new(); | ||
// We want to make sure we have the expn_id set so that we can use unstable methods | ||
let span = Span { expn_id: cx.backtrace(), .. span }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you find that this was necessary? I'm under the impression that the macro infrastructure manages re-spanning everything after a macro expansion?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It did not appear to respan - I think only the macro_rules!
infrastructure may do that.
Looks great. Is it worth putting these under a different feature gate to |
Switching from generic bounds to trait objects and having un-inlined inner methods should cut down on the size of Debug impls, since we care about the speed of a Debug implementation way less than binary bloat.
f61cd26
to
3181213
Compare
Turns out it's basically a wash, codegen wise.
So it turns out that no-inline silliness actually ends up a tiny bit smaller than inline silliness: https://gist.github.com/sfackler/a9300bce13ad166cd35b. Looks like the builder structs are small enough that the copies don't matter. I pushed a commit that cuts out all the inline annotations. |
Oh, and there doesn't appear to be much of a difference one way or another for overall binary sizes before and after the |
Thanks for investigating!
Ah well, it probably at least paves the way in the future for such changes though. |
This looks great to me! r=me with a feature name that's not |
I've made some minor changes from the implementation attached to the RFC to try to minimize codegen. The methods now take `&Debug` trait objects rather than being parameterized and there are inlined stub methods that call to non-inlined methods to do the work. r? @alexcrichton cc @huonw for the `derive(Debug)` changes.
💔 Test failed - auto-linux-32-nopt-t |
@bors retry Seems like a spurious error?? |
⚡ Previous build results for auto-linux-32-opt, auto-linux-64-nopt-t, auto-mac-32-opt, auto-mac-64-nopt-t, auto-mac-64-opt are reusable. Rebuilding only auto-linux-32-nopt-t, auto-linux-64-opt, auto-linux-64-x-android-t, auto-win-32-nopt-t, auto-win-32-opt, auto-win-64-nopt-t, auto-win-64-opt... |
⛄ The build was interrupted to prioritize another pull request. |
⚡ Previous build results for auto-linux-32-opt, auto-linux-64-nopt-t, auto-mac-32-opt, auto-mac-64-nopt-t, auto-mac-64-opt are reusable. Rebuilding only auto-linux-32-nopt-t, auto-linux-64-opt, auto-linux-64-x-android-t, auto-win-32-nopt-t, auto-win-32-opt, auto-win-64-nopt-t, auto-win-64-opt... |
⛄ The build was interrupted to prioritize another pull request. |
I've made some minor changes from the implementation attached to the RFC to try to minimize codegen. The methods now take `&Debug` trait objects rather than being parameterized and there are inlined stub methods that call to non-inlined methods to do the work. r? @alexcrichton cc @huonw for the `derive(Debug)` changes.
Should |
keywords: pretty debug builders |
@SimonSapin It would be great is |
I've made some minor changes from the implementation attached to the RFC to try to minimize codegen. The methods now take
&Debug
trait objects rather than being parameterized and there are inlined stub methods that call to non-inlined methods to do the work.r? @alexcrichton
cc @huonw for the
derive(Debug)
changes.